import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('articles')
export class Article {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 200 })
  title: string;

  @Column({ type: 'text', nullable: true })
  content: string;

  @Column({ name: 'author_id' })
  authorId: number;

  @Column({ name: 'category_id' })
  categoryId: number;

  @Column({ default: 0 })
  status: number; // 0: 草稿, 1: 已发布, 2: 已下架

  @Column({ name: 'publish_time', nullable: true })
  publishTime: Date;

  @Column({ name: 'created_at' })
  @CreateDateColumn()
  createdAt: Date;

  @Column({ name: 'updated_at' })
  @UpdateDateColumn()
  updatedAt: Date;
}